package homework;

import java.util.Calendar;
import java.util.Scanner;

/**
 * @classname:demo02
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/10 19:51
 * @version: 0.1
 * @since:1.8
 */
public class demo02 {
    private static final String PATTERN = "yyyy-MM-dd";

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Calendar calendar = Calendar.getInstance();
        System.out.println("请输入年份");
        int year = input.nextInt();
        System.out.println("请输入月份");
        int mounth = input.nextInt();
        calendar.set(year, mounth - 1, 1);
        System.out.println("日\t一\t二\t三\t四\t五\t六");

        int dayofweek = calendar.get(Calendar.DAY_OF_WEEK);
        for (int i1 = 1; i1 < dayofweek; i1++) {
            System.out.print("\t");
        }

        //拿到当前月份的最多天数
        int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

        for (int i = 1; i <= actualMaximum; i++) {
            //设置月份为增长月份
            calendar.set(Calendar.DAY_OF_MONTH, i);
            //输出天数
            System.out.print(i + "\t");
            //一周有7天 当前是第七天 执行操作
            if (calendar.get(Calendar.DAY_OF_WEEK) == 7) {
                System.out.println();
            }
        }

    }
}
